package com.socialbank.web.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.socialbank.web.FinanceBean.BankInsurance;
import com.socialbank.web.bean.ResultMessage;
import com.socialbank.web.service.BankInsuranceService;

@Controller
@RequestMapping("/bank/insurance")
public class BankInsuranceController {
	@Resource
	private BankInsuranceService bankInsuranceService;
	
	@RequestMapping("/save")
	@ResponseBody
	protected Object save(MultipartFile file,BankInsurance bankInsurance){
		bankInsuranceService.save(file, bankInsurance);
		Map<String, Object> result = new HashMap<>();
		return new ResultMessage(200,"",result);
	} 
	
	@RequestMapping("/deleteById")
	@ResponseBody
	protected Object deleteById(int id){
		bankInsuranceService.deleteById(id);
		Map<String, Object> result = new HashMap<>();
		return new ResultMessage(200,"",result);
	} 
	@RequestMapping("/getList")
	@ResponseBody
	protected Object getList(BankInsurance bankInsurance){
		List<BankInsurance> bankInsurances=new ArrayList<BankInsurance>();
		bankInsurances=bankInsuranceService.getList(bankInsurance);
		Map<String, Object> result = new HashMap<>();
		result.put("data", bankInsurances);
		return new ResultMessage(200,"",result);
	} 
	
	@RequestMapping("/findById")
	@ResponseBody
	protected Object findById(int id){
		BankInsurance bankInsurance=bankInsuranceService.findById(id);
		Map<String, Object> result = new HashMap<>();
		result.put("data", bankInsurance);
		return new ResultMessage(200,"",result);
	} 
	
	@RequestMapping("/updateById")
	@ResponseBody
	protected Object updateById(MultipartFile file,BankInsurance bankInsurance){
		bankInsuranceService.updateById(file,bankInsurance);
		Map<String, Object> result = new HashMap<>();
		return new ResultMessage(200,"",result);
	} 

	
}
